package model;

import java.sql.*;
import java.util.Date;
import dal.*;
import util.*;

public class DocumentModel implements IModel {

	public static class FieldNames {
		public static String Id = "Id";
		public static String Code = "Code";
		public static String IsTemplate = "IsTemplate";
		public static String ObjectType = "ObjectType";
		public static String ObjectId = "ObjectId";
		public static String Status = "Status";
		public static String Notification = "Notification";
		public static String Created = "Created";
		public static String Creator = "Creator";
		public static String Updated = "Updated";
		public static String Updator = "Updator";
		public static String Deleted = "Deleted";
		public static String DeletionTime = "DeletionTime";
		public static String DocumentName = "DocumentName";
		public static String Extension = "Extension";
		public static String Description = "Description";
		public static String Remark = "Remark";
		public static String DocumentType = "DocumentType";

	}

	public class ErrorMessages {
		public String Id = "";
		public String Code = "";
		public String IsTemplate = "";
		public String ObjectType = "";
		public String ObjectId = "";
		public String Status = "";
		public String Notification = "";
		public String Created = "";
		public String Creator = "";
		public String Updated = "";
		public String Updator = "";
		public String Deleted = "";
		public String DeletionTime = "";
		public String DocumentName = "";
		public String Extension = "";
		public String Description = "";
		public String Remark = "";
		public String DocumentType = "";

	}

	public ErrorMessages errMsgs = new ErrorMessages();

	public String[] errMsgList = null;

	// private variables
	private int _id = Integer.MIN_VALUE;
	private String _code = null;
	private boolean _is_template = false;
	private boolean _isis_templateSet = false;
	private String _object_type = null;
	private int _object_id = Integer.MIN_VALUE;
	private int _status = Integer.MIN_VALUE;
	private int _notification = Integer.MIN_VALUE;
	private Date _created = null;
	private int _creator = Integer.MIN_VALUE;
	private Date _updated = null;
	private int _updator = Integer.MIN_VALUE;
	private boolean _deleted = false;
	private boolean _isdeletedSet = false;
	private Date _deletion_time = null;
	private String _document_name = null;
	private String _extension = null;
	private String _description = null;
	private String _remark = null;
	private int _document_type = Integer.MIN_VALUE;

	public DocumentModel() {
	}

	// get/set
	public int getId() {
		return _id;
	}

	public void setId(int value) {
		_id = value;
	}

	public String getIdToString() {
		if (_id == Integer.MIN_VALUE || _id == Integer.MAX_VALUE) {
			return "";
		} else {
			return Integer.toString(_id);
		}
	}

	public String getCode() {
		return _code;
	}

	public void setCode(String value) {
		_code = value;
	}

	public String getCodeToString() {
		if (_code != null) {
			return HtmlUtil.genHtml(_code);
		} else {
			return "";
		}
	}

	public boolean getIsTemplate() {
		return _is_template;
	}

	public void setIsTemplate(boolean value) {
		_is_template = value;
		_isis_templateSet = true;
	}

	public boolean getIsTemplateSet() {
		return _isis_templateSet;
	}

	public String getIsTemplateToString() {
		if (_isis_templateSet) {
			return HtmlUtil.genHtml(_is_template);
		} else {
			return "";
		}
	}

	public String getObjectType() {
		return _object_type;
	}

	public void setObjectType(String value) {
		_object_type = value;
	}

	public String getObjectTypeToString() {
		if (_object_type != null) {
			return HtmlUtil.genHtml(_object_type);
		} else {
			return "";
		}
	}

	public int getObjectId() {
		return _object_id;
	}

	public void setObjectId(int value) {
		_object_id = value;
	}

	public String getObjectIdToString() {
		if (_object_id == Integer.MIN_VALUE || _object_id == Integer.MAX_VALUE) {
			return "";
		} else {
			return Integer.toString(_object_id);
		}
	}

	public int getStatus() {
		return _status;
	}

	public void setStatus(int value) {
		_status = value;
	}

	public String getStatusToString() {
		if (_status == Integer.MIN_VALUE || _status == Integer.MAX_VALUE) {
			return "";
		} else {
			return Integer.toString(_status);
		}
	}

	public int getNotification() {
		return _notification;
	}

	public void setNotification(int value) {
		_notification = value;
	}

	public String getNotificationToString() {
		if (_notification == Integer.MIN_VALUE
				|| _notification == Integer.MAX_VALUE) {
			return "";
		} else {
			return Integer.toString(_notification);
		}
	}

	public Date getCreated() {
		return _created;
	}

	public void setCreated(Date value) {
		_created = value;
	}

	public String getCreatedToString() {
		if (_created != null) {
			return StringUtil.toDateTimeString(_created);
		} else {
			return "";
		}
	}

	public int getCreator() {
		return _creator;
	}

	public void setCreator(int value) {
		_creator = value;
	}

	public String getCreatorToString() {
		if (_creator == Integer.MIN_VALUE || _creator == Integer.MAX_VALUE) {
			return "";
		} else {
			return Integer.toString(_creator);
		}
	}

	public Date getUpdated() {
		return _updated;
	}

	public void setUpdated(Date value) {
		_updated = value;
	}

	public String getUpdatedToString() {
		if (_updated != null) {
			return StringUtil.toDateTimeString(_updated);
		} else {
			return "";
		}
	}

	public int getUpdator() {
		return _updator;
	}

	public void setUpdator(int value) {
		_updator = value;
	}

	public String getUpdatorToString() {
		if (_updator == Integer.MIN_VALUE || _updator == Integer.MAX_VALUE) {
			return "";
		} else {
			return Integer.toString(_updator);
		}
	}

	public boolean getDeleted() {
		return _deleted;
	}

	public void setDeleted(boolean value) {
		_deleted = value;
		_isdeletedSet = true;
	}

	public boolean getDeletedSet() {
		return _isdeletedSet;
	}

	public String getDeletedToString() {
		if (_isdeletedSet) {
			return HtmlUtil.genHtml(_deleted);
		} else {
			return "";
		}
	}

	public Date getDeletionTime() {
		return _deletion_time;
	}

	public void setDeletionTime(Date value) {
		_deletion_time = value;
	}

	public String getDeletionTimeToString() {
		if (_deletion_time != null) {
			return StringUtil.toDateTimeString(_deletion_time);
		} else {
			return "";
		}
	}

	public String getDocumentName() {
		return _document_name;
	}

	public void setDocumentName(String value) {
		_document_name = value;
	}

	public String getDocumentNameToString() {
		if (_document_name != null) {
			return HtmlUtil.genHtml(_document_name);
		} else {
			return "";
		}
	}

	public String getExtension() {
		return _extension;
	}

	public void setExtension(String value) {
		_extension = value;
	}

	public String getExtensionToString() {
		if (_extension != null) {
			return HtmlUtil.genHtml(_extension);
		} else {
			return "";
		}
	}

	public String getDescription() {
		return _description;
	}

	public void setDescription(String value) {
		_description = value;
	}

	public String getDescriptionToString() {
		if (_description != null) {
			return HtmlUtil.genHtml(_description);
		} else {
			return "";
		}
	}

	public String getRemark() {
		return _remark;
	}

	public void setRemark(String value) {
		_remark = value;
	}

	public String getRemarkToString() {
		if (_remark != null) {
			return HtmlUtil.genHtml(_remark);
		} else {
			return "";
		}
	}

	public int getDocumentType() {
		return _document_type;
	}

	public void setDocumentType(int value) {
		_document_type = value;
	}

	public String getDocumentTypeToString() {
		if (_document_type == Integer.MIN_VALUE
				|| _document_type == Integer.MAX_VALUE) {
			return "";
		} else {
			return Integer.toString(_document_type);
		}
	}

	// implement method
	public String getName() {
		return _document_name;
	}

	@Override
	public int[] getPrimaryKey() {
		int[] ids = new int[1];
		ids[0] = getId();
		return ids;
	}

	@Override
	public IModel readFromResultSet(ResultSet rs) throws SQLException {
		DocumentModel model = null;

		model = new DocumentModel();

		// read fields
		{
			int value = rs.getInt("id");
			if (!rs.wasNull()) {
				model.setId(value);
			}
		}
		{
			String value = rs.getString("code");
			if (!rs.wasNull()) {
				model.setCode(value);
			}
		}
		{
			boolean value = rs.getBoolean("is_template");
			if (!rs.wasNull()) {
				model.setIsTemplate(value);
			}
		}
		{
			String value = rs.getString("object_type");
			if (!rs.wasNull()) {
				model.setObjectType(value);
			}
		}
		{
			int value = rs.getInt("object_id");
			if (!rs.wasNull()) {
				model.setObjectId(value);
			}
		}
		{
			int value = rs.getInt("status");
			if (!rs.wasNull()) {
				model.setStatus(value);
			}
		}
		{
			int value = rs.getInt("notification");
			if (!rs.wasNull()) {
				model.setNotification(value);
			}
		}
		{
			Date value = rs.getTimestamp("created");
			if (!rs.wasNull()) {
				model.setCreated(value);
			}
		}
		{
			int value = rs.getInt("creator");
			if (!rs.wasNull()) {
				model.setCreator(value);
			}
		}
		{
			Date value = rs.getTimestamp("updated");
			if (!rs.wasNull()) {
				model.setUpdated(value);
			}
		}
		{
			int value = rs.getInt("updator");
			if (!rs.wasNull()) {
				model.setUpdator(value);
			}
		}
		{
			boolean value = rs.getBoolean("deleted");
			if (!rs.wasNull()) {
				model.setDeleted(value);
			}
		}
		{
			Date value = rs.getTimestamp("deletion_time");
			if (!rs.wasNull()) {
				model.setDeletionTime(value);
			}
		}
		{
			String value = rs.getString("document_name");
			if (!rs.wasNull()) {
				model.setDocumentName(value);
			}
		}
		{
			String value = rs.getString("extension");
			if (!rs.wasNull()) {
				model.setExtension(value);
			}
		}
		{
			String value = rs.getString("description");
			if (!rs.wasNull()) {
				model.setDescription(value);
			}
		}
		{
			String value = rs.getString("remark");
			if (!rs.wasNull()) {
				model.setRemark(value);
			}
		}
		{
			int value = rs.getInt("document_type");
			if (!rs.wasNull()) {
				model.setDocumentType(value);
			}
		}

		return model;
	}

	@Override
	public PreparedStatement genSelectStatement(Connection dbConn, IModel query)
			throws SQLException {
		String sql = "SELECT * FROM sp_document_select(:id);";
		NamedParameterPreparedStatement st = new NamedParameterPreparedStatement(
				dbConn, sql);

		DocumentModel obj = (DocumentModel) query;

		// set parameters
		st.setObject("id", obj.getId());

		return st.getPreparedStatement();
	}

	@Override
	public PreparedStatement genSelectListStatement(Connection dbConn,
			IModelExt query) throws SQLException {
		String sql = "SELECT * FROM sp_document_selectList(:limit, :offset, :id,:code,:is_template,:object_type,:object_id,:status,:notification,:createdFrom,:createdTo,:creator,:updatedFrom,:updatedTo,:updator,:deleted,:deletion_timeFrom,:deletion_timeTo,:document_name,:extension,:description,:remark,:document_type)";

		NamedParameterPreparedStatement st = new NamedParameterPreparedStatement(
				dbConn, sql);

		DocumentModelExt obj = (DocumentModelExt) query;

		if (obj.getLimit() != Integer.MIN_VALUE) {
			st.setObject("limit", obj.getLimit());
		} else {
			st.setObject("limit", Integer.MAX_VALUE);
		}
		if (obj.getOffset() != Integer.MIN_VALUE) {
			st.setObject("offset", obj.getOffset());
		} else {
			st.setObject("offset", 0);
		}

		// set parameters
		if (obj.getId() != Integer.MIN_VALUE) {
			st.setObject("id", obj.getId());
		} else {
			st.setObject("id", null);
		}
		if (obj.getCode() != null) {
			st.setObject("code", obj.getCode());
		} else {
			st.setObject("code", null);
		}
		if (obj.getIsTemplateSet()) {
			st.setObject("is_template", obj.getIsTemplate());
		} else {
			st.setObject("is_template", null);
		}
		if (obj.getObjectType() != null) {
			st.setObject("object_type", obj.getObjectType());
		} else {
			st.setObject("object_type", null);
		}
		if (obj.getObjectId() != Integer.MIN_VALUE) {
			st.setObject("object_id", obj.getObjectId());
		} else {
			st.setObject("object_id", null);
		}
		if (obj.getStatus() != Integer.MIN_VALUE) {
			st.setObject("status", obj.getStatus());
		} else {
			st.setObject("status", null);
		}
		if (obj.getNotification() != Integer.MIN_VALUE) {
			st.setObject("notification", obj.getNotification());
		} else {
			st.setObject("notification", null);
		}
		if (obj.getCreatedFrom() != null) {
			st.setObject("createdFrom", obj.getCreatedFrom());
		} else {
			st.setObject("createdFrom", null);
		}
		if (obj.getCreatedTo() != null) {
			st.setObject("createdTo", obj.getCreatedTo());
		} else {
			st.setObject("createdTo", null);
		}
		if (obj.getCreator() != Integer.MIN_VALUE) {
			st.setObject("creator", obj.getCreator());
		} else {
			st.setObject("creator", null);
		}
		if (obj.getUpdatedFrom() != null) {
			st.setObject("updatedFrom", obj.getUpdatedFrom());
		} else {
			st.setObject("updatedFrom", null);
		}
		if (obj.getUpdatedTo() != null) {
			st.setObject("updatedTo", obj.getUpdatedTo());
		} else {
			st.setObject("updatedTo", null);
		}
		if (obj.getUpdator() != Integer.MIN_VALUE) {
			st.setObject("updator", obj.getUpdator());
		} else {
			st.setObject("updator", null);
		}
		if (obj.getDeletedSet()) {
			st.setObject("deleted", obj.getDeleted());
		} else {
			st.setObject("deleted", null);
		}
		if (obj.getDeletionTimeFrom() != null) {
			st.setObject("deletion_timeFrom", obj.getDeletionTimeFrom());
		} else {
			st.setObject("deletion_timeFrom", null);
		}
		if (obj.getDeletionTimeTo() != null) {
			st.setObject("deletion_timeTo", obj.getDeletionTimeTo());
		} else {
			st.setObject("deletion_timeTo", null);
		}
		if (obj.getDocumentName() != null) {
			st.setObject("document_name", obj.getDocumentName());
		} else {
			st.setObject("document_name", null);
		}
		if (obj.getExtension() != null) {
			st.setObject("extension", obj.getExtension());
		} else {
			st.setObject("extension", null);
		}
		if (obj.getDescription() != null) {
			st.setObject("description", obj.getDescription());
		} else {
			st.setObject("description", null);
		}
		if (obj.getRemark() != null) {
			st.setObject("remark", obj.getRemark());
		} else {
			st.setObject("remark", null);
		}
		if (obj.getDocumentType() != Integer.MIN_VALUE) {
			st.setObject("document_type", obj.getDocumentType());
		} else {
			st.setObject("document_type", null);
		}

		return st.getPreparedStatement();
	}

	@Override
	public PreparedStatement genInsertStatement(Connection dbConn, IModel model)
			throws SQLException {
		String sql = "SELECT sp_document_insert(:code,:is_template,:object_type,:object_id,:status,:notification,:creator,:document_name,:extension,:description,:remark,:document_type)";
		NamedParameterPreparedStatement st = new NamedParameterPreparedStatement(
				dbConn, sql);

		DocumentModel obj = (DocumentModel) model;

		// set parameters here
		if (obj.getCode() != null) {
			st.setObject("code", obj.getCode());
		} else {
			st.setObject("code", null);
		}
		if (obj.getIsTemplateSet()) {
			st.setObject("is_template", obj.getIsTemplate());
		} else {
			st.setObject("is_template", null);
		}
		if (obj.getObjectType() != null) {
			st.setObject("object_type", obj.getObjectType());
		} else {
			st.setObject("object_type", null);
		}
		if (obj.getObjectId() != Integer.MIN_VALUE) {
			st.setObject("object_id", obj.getObjectId());
		} else {
			st.setObject("object_id", null);
		}
		if (obj.getStatus() != Integer.MIN_VALUE) {
			st.setObject("status", obj.getStatus());
		} else {
			st.setObject("status", null);
		}
		if (obj.getNotification() != Integer.MIN_VALUE) {
			st.setObject("notification", obj.getNotification());
		} else {
			st.setObject("notification", null);
		}
		if (obj.getCreator() != Integer.MIN_VALUE) {
			st.setObject("creator", obj.getCreator());
		} else {
			st.setObject("creator", null);
		}
		if (obj.getDocumentName() != null) {
			st.setObject("document_name", obj.getDocumentName());
		} else {
			st.setObject("document_name", null);
		}
		if (obj.getExtension() != null) {
			st.setObject("extension", obj.getExtension());
		} else {
			st.setObject("extension", null);
		}
		if (obj.getDescription() != null) {
			st.setObject("description", obj.getDescription());
		} else {
			st.setObject("description", null);
		}
		if (obj.getRemark() != null) {
			st.setObject("remark", obj.getRemark());
		} else {
			st.setObject("remark", null);
		}
		if (obj.getDocumentType() != Integer.MIN_VALUE) {
			st.setObject("document_type", obj.getDocumentType());
		} else {
			st.setObject("document_type", null);
		}

		return st.getPreparedStatement();
	}

	@Override
	public PreparedStatement genUpdateStatement(Connection dbConn, IModel model)
			throws SQLException {
		String sql = "SELECT sp_document_update(:id,:code,:is_template,:object_type,:object_id,:status,:notification,:updator,:deleted,:deletion_time,:document_name,:extension,:description,:remark,:document_type)";

		NamedParameterPreparedStatement st = new NamedParameterPreparedStatement(
				dbConn, sql);

		DocumentModel obj = (DocumentModel) model;

		// set parameters here
		if (obj.getId() != Integer.MIN_VALUE) {
			st.setObject("id", obj.getId());
		} else {
			st.setObject("id", null);
		}
		if (obj.getCode() != null) {
			st.setObject("code", obj.getCode());
		} else {
			st.setObject("code", null);
		}
		if (obj.getIsTemplateSet()) {
			st.setObject("is_template", obj.getIsTemplate());
		} else {
			st.setObject("is_template", null);
		}
		if (obj.getObjectType() != null) {
			st.setObject("object_type", obj.getObjectType());
		} else {
			st.setObject("object_type", null);
		}
		if (obj.getObjectId() != Integer.MIN_VALUE) {
			st.setObject("object_id", obj.getObjectId());
		} else {
			st.setObject("object_id", null);
		}
		if (obj.getStatus() != Integer.MIN_VALUE) {
			st.setObject("status", obj.getStatus());
		} else {
			st.setObject("status", null);
		}
		if (obj.getNotification() != Integer.MIN_VALUE) {
			st.setObject("notification", obj.getNotification());
		} else {
			st.setObject("notification", null);
		}
		if (obj.getUpdator() != Integer.MIN_VALUE) {
			st.setObject("updator", obj.getUpdator());
		} else {
			st.setObject("updator", null);
		}
		if (obj.getDeletedSet()) {
			st.setObject("deleted", obj.getDeleted());
		} else {
			st.setObject("deleted", null);
		}
		if (obj.getDeletionTime() != null) {
			st.setObject("deletion_time", obj.getDeletionTime());
		} else {
			st.setObject("deletion_time", null);
		}
		if (obj.getDocumentName() != null) {
			st.setObject("document_name", obj.getDocumentName());
		} else {
			st.setObject("document_name", null);
		}
		if (obj.getExtension() != null) {
			st.setObject("extension", obj.getExtension());
		} else {
			st.setObject("extension", null);
		}
		if (obj.getDescription() != null) {
			st.setObject("description", obj.getDescription());
		} else {
			st.setObject("description", null);
		}
		if (obj.getRemark() != null) {
			st.setObject("remark", obj.getRemark());
		} else {
			st.setObject("remark", null);
		}
		if (obj.getDocumentType() != Integer.MIN_VALUE) {
			st.setObject("document_type", obj.getDocumentType());
		} else {
			st.setObject("document_type", null);
		}

		return st.getPreparedStatement();
	}

	@Override
	public PreparedStatement genDeleteStatement(Connection dbConn, IModel query)
			throws SQLException {
		String sql = "select sp_document_delete(:id);";
		NamedParameterPreparedStatement st = new NamedParameterPreparedStatement(
				dbConn, sql);

		DocumentModel obj = (DocumentModel) query;

		// set primary keys
		st.setObject("id", obj.getId());

		return st.getPreparedStatement();
	}

	@Override
	public PreparedStatement genCountStatement(Connection dbConn,
			IModelExt input) throws SQLException {
		String sql = "SELECT sp_document_count(:id,:code,:is_template,:object_type,:object_id,:status,:notification,:createdFrom,:createdTo,:creator,:updatedFrom,:updatedTo,:updator,:deleted,:deletion_timeFrom,:deletion_timeTo,:document_name,:extension,:description,:remark,:document_type)";

		NamedParameterPreparedStatement st = new NamedParameterPreparedStatement(
				dbConn, sql);

		DocumentModelExt obj = (DocumentModelExt) input;

		// set parameters here
		if (obj.getId() != Integer.MIN_VALUE) {
			st.setObject("id", obj.getId());
		} else {
			st.setObject("id", null);
		}
		if (obj.getCode() != null) {
			st.setObject("code", obj.getCode());
		} else {
			st.setObject("code", null);
		}
		if (obj.getIsTemplateSet()) {
			st.setObject("is_template", obj.getIsTemplate());
		} else {
			st.setObject("is_template", null);
		}
		if (obj.getObjectType() != null) {
			st.setObject("object_type", obj.getObjectType());
		} else {
			st.setObject("object_type", null);
		}
		if (obj.getObjectId() != Integer.MIN_VALUE) {
			st.setObject("object_id", obj.getObjectId());
		} else {
			st.setObject("object_id", null);
		}
		if (obj.getStatus() != Integer.MIN_VALUE) {
			st.setObject("status", obj.getStatus());
		} else {
			st.setObject("status", null);
		}
		if (obj.getNotification() != Integer.MIN_VALUE) {
			st.setObject("notification", obj.getNotification());
		} else {
			st.setObject("notification", null);
		}
		if (obj.getCreatedFrom() != null) {
			st.setObject("createdFrom", obj.getCreatedFrom());
		} else {
			st.setObject("createdFrom", null);
		}
		if (obj.getCreatedTo() != null) {
			st.setObject("createdTo", obj.getCreatedTo());
		} else {
			st.setObject("createdTo", null);
		}
		if (obj.getCreator() != Integer.MIN_VALUE) {
			st.setObject("creator", obj.getCreator());
		} else {
			st.setObject("creator", null);
		}
		if (obj.getUpdatedFrom() != null) {
			st.setObject("updatedFrom", obj.getUpdatedFrom());
		} else {
			st.setObject("updatedFrom", null);
		}
		if (obj.getUpdatedTo() != null) {
			st.setObject("updatedTo", obj.getUpdatedTo());
		} else {
			st.setObject("updatedTo", null);
		}
		if (obj.getUpdator() != Integer.MIN_VALUE) {
			st.setObject("updator", obj.getUpdator());
		} else {
			st.setObject("updator", null);
		}
		if (obj.getDeletedSet()) {
			st.setObject("deleted", obj.getDeleted());
		} else {
			st.setObject("deleted", null);
		}
		if (obj.getDeletionTimeFrom() != null) {
			st.setObject("deletion_timeFrom", obj.getDeletionTimeFrom());
		} else {
			st.setObject("deletion_timeFrom", null);
		}
		if (obj.getDeletionTimeTo() != null) {
			st.setObject("deletion_timeTo", obj.getDeletionTimeTo());
		} else {
			st.setObject("deletion_timeTo", null);
		}
		if (obj.getDocumentName() != null) {
			st.setObject("document_name", obj.getDocumentName());
		} else {
			st.setObject("document_name", null);
		}
		if (obj.getExtension() != null) {
			st.setObject("extension", obj.getExtension());
		} else {
			st.setObject("extension", null);
		}
		if (obj.getDescription() != null) {
			st.setObject("description", obj.getDescription());
		} else {
			st.setObject("description", null);
		}
		if (obj.getRemark() != null) {
			st.setObject("remark", obj.getRemark());
		} else {
			st.setObject("remark", null);
		}
		if (obj.getDocumentType() != Integer.MIN_VALUE) {
			st.setObject("document_type", obj.getDocumentType());
		} else {
			st.setObject("document_type", null);
		}

		return st.getPreparedStatement();
	}

	/*
	 * private String fillHtmlTemplate(String template) { String html = template
	 * .replace(":id", Integer.toString(_id)) .replace(":code",
	 * HtmlUtil.genHtml(_code)) .replace(":is_template",
	 * HtmlUtil.genHtml(_isis_templateSet, _is_template))
	 * .replace(":object_type", HtmlUtil.genHtml(_object_type))
	 * .replace(":object_id", Integer.toString(_object_id)) .replace(":status",
	 * Integer.toString(_status)) .replace(":notification",
	 * Integer.toString(_notification)) .replace(":created",
	 * StringUtil.toDateTimeString(_created)) .replace(":creator",
	 * Integer.toString(_creator)) .replace(":updated",
	 * StringUtil.toDateTimeString(_updated)) .replace(":updator",
	 * Integer.toString(_updator)) .replace(":deleted",
	 * HtmlUtil.genHtml(_isdeletedSet, _deleted)) .replace(":deletion_time",
	 * StringUtil.toDateTimeString(_deletion_time)) .replace(":document_name",
	 * HtmlUtil.genHtml(_document_name)) .replace(":extension",
	 * HtmlUtil.genHtml(_extension)) .replace(":description",
	 * HtmlUtil.genHtml(_description)) .replace(":remark",
	 * HtmlUtil.genHtml(_remark)) .replace(":document_type",
	 * Integer.toString(_document_type))
	 * 
	 * ; return html; }
	 */

	/*
	 * private String fillHtmlTemplate(String template) { String html = template
	 * .replace(":Id", Integer.toString(_Id)) .replace(":Code",
	 * HtmlUtil.genHtml(_Code)) .replace(":IsTemplate",
	 * HtmlUtil.genHtml(_isIsTemplateSet, _IsTemplate)) .replace(":ObjectType",
	 * HtmlUtil.genHtml(_ObjectType)) .replace(":ObjectId",
	 * Integer.toString(_ObjectId)) .replace(":Status",
	 * Integer.toString(_Status)) .replace(":Notification",
	 * Integer.toString(_Notification)) .replace(":Created",
	 * StringUtil.toDateTimeString(_Created)) .replace(":Creator",
	 * Integer.toString(_Creator)) .replace(":Updated",
	 * StringUtil.toDateTimeString(_Updated)) .replace(":Updator",
	 * Integer.toString(_Updator)) .replace(":Deleted",
	 * HtmlUtil.genHtml(_isDeletedSet, _Deleted)) .replace(":DeletionTime",
	 * StringUtil.toDateTimeString(_DeletionTime)) .replace(":DocumentName",
	 * HtmlUtil.genHtml(_DocumentName)) .replace(":Extension",
	 * HtmlUtil.genHtml(_Extension)) .replace(":Description",
	 * HtmlUtil.genHtml(_Description)) .replace(":Remark",
	 * HtmlUtil.genHtml(_Remark)) .replace(":DocumentType",
	 * Integer.toString(_DocumentType))
	 * 
	 * ; return html; }
	 */

	public DocumentModel clone() {
		DocumentModel obj = new DocumentModel();

		obj.setId(getId());
		obj.setCode(getCode());
		obj.setIsTemplate(getIsTemplate());
		obj.setObjectType(getObjectType());
		obj.setObjectId(getObjectId());
		obj.setStatus(getStatus());
		obj.setNotification(getNotification());
		obj.setCreated(getCreated());
		obj.setCreator(getCreator());
		obj.setUpdated(getUpdated());
		obj.setUpdator(getUpdator());
		obj.setDeleted(getDeleted());
		obj.setDeletionTime(getDeletionTime());
		obj.setDocumentName(getDocumentName());
		obj.setExtension(getExtension());
		obj.setDescription(getDescription());
		obj.setRemark(getRemark());
		obj.setDocumentType(getDocumentType());

		return obj;
	}

}